package com.diver.flinkdemo.utils;

import com.alibaba.fastjson.JSONObject;

import java.util.Locale;

/**
 * @author hesc
 * @date 2022-08-22
 * @Description 福建校园云加密工具类
 */
public class FJSignUtils {

    //APPID
    public static final String appId = "112";
    //钥匙key
    public static final String appKey = "DKwaSdIxR9lAxOy4";

    //测试
//    public static final String url = "http://121.204.166.132:8089/portal/openapi";
    public static final String url = "https://yzs.fj.cn/portal/openapi";

    /**
     * 获取当前登入用户信息 url
     */
    public static final String GET_USER_INFO_URL= "/user/getUserInfo";

    /**
     * 获取班级信息 url
     */
    public static final String GET_SCHOOL_INFO_URL= "/user/getSchoolInfo";

    /**
     * 获取班级信息 url
     */
    public static final String GET_CLASS_INFO_URL= "/user/getClassInfo";



    public static String getSign(String randomStr, String time) {
        String sign = "appId=" + appId + "&randomStr=" + randomStr + "&time=" + time + "&key=" + appKey;
        sign = Md5Utils.md5(sign);
        sign = sign.toUpperCase(Locale.ROOT);
        return sign;
    }

    public static void main(String[] args) {
//        String randomStr = UUIDUtil.uuid();
//        String time = DateUtil.getNowDateWholePoint("yyyyMMddHHmmss");
//        getSign(randomStr, time);
//        String a = null;
        String randomStr = UUIDUtil.uuid();
        String time = DateUtil.getNowDateWholePoint("yyyyMMddHHmmss");
        JSONObject sendJson = new JSONObject();
        sendJson.put("appId", FJSignUtils.appId);
        sendJson.put("time", time);
        sendJson.put("randomStr", randomStr);
        sendJson.put("sign", FJSignUtils.getSign(randomStr, time));
        String imei = AESUtils.enCode("866743050613312", appKey);
        System.out.println(imei);
        String imei1 = AESUtils.deCode(imei, appKey);
        System.out.println(imei1);
    }
}
